[SUBROUTINE]
version = 1.14
icon = parting.png
name = _("Parting Off")
type = parting
help = _("<b>Parting single or multiple pieces</b>&#10;Cutter orientation should be 6, 9 or None")
order = act hx b_x e_x hz ref b_z b_zu b_zg hp c

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_HX]
name = _("X axis")
type = sub-header

[PARAM_B_X]
name = _("Begin diameter")
type = float
icon = x.png
value = 1.0
metric_value = 25.0
minimum_value = 0.0
not_allowed = 0
header = hx

[PARAM_E_X]
name = _("End diameter")
type = float
icon = x-end.png
value = 0.0
metric_value = 0.0
header = hx

[PARAM_HZ]
name = _("Z axis")
type = sub-header

[PARAM_REF]
name = _("Reference")
type = float
value = 0.0
metric_value = 0.0
header = hz
icon = z.png

[PARAM_B_Z]
name = _("First cut")
icon = z-end.png
type = combo-user
options = _("User defined=0:Current position=1:G-Code=2")
value = 0
tool_tip = _("Will part at this position")
header = hz
links = b_zu=0:b_zg=2

[PARAM_B_ZU]
type = float
value = -1.0
metric_value = -25.0
header = hz
hidden = 1

[PARAM_B_ZG]
type = gcode
value =
header = hz
hidden = 1

[PARAM_HP]
name = _("Params")
type = sub-header

[PARAM_C]
name = _("Copies")
icon = copies.png
type = int
value = 1
minimum_value = 1
header = hp
tool_tip = _("Copies length will be 'First' minus 'Reference'")

[VALIDATION]
content =
	if #param_act == 1 :
		if self.check_hash('#param_b_x', 1) <= self.check_hash('#param_e_x', 0) :
			self.msg_inv(_('Begin X must be greater than End X'), 1)
			VALIDATED = False
			
		if TOOL_TABLE.get_tool_orient() not in [0, 6, 9] :
			self.msg_inv(_('Cutter orientation should be 6, 9 or 0'), 2)

[CALL]
content =
	(begin #sub_name)
	(author : Fernand Veilleux)
	o<#self_id_act> if [#param_act]
		o<select>  CALL [42] [#param_b_z] [#param_b_zu] [#<_z>] [#param_b_zg]
		G0 X[#<_wp_dia_od> + #<_x_rapid>]
		M#<_cooling_mode>
	
		#<b_x#ID> = [#param_b_x / 2 * #<_diameter_mode>]
		#<e_x#ID> = [#param_e_x / 2 * #<_diameter_mode>]
	
		#<z#ID> = #param_ref
		o<#self_id1> repeat [#param_c]
			#<z#ID> = [#<z#ID> + #42 - [#param_ref]]
			G0 Z#<z#ID>
			G0 X#<b_x#ID>
			G1 X#<e_x#ID>
			G0 X[#<_wp_dia_od> + #<_x_rapid>]
		o<#self_id1> endrepeat
	
		M9 (cooling off)
	
	o<#self_id_act> endif
	(end #sub_name)
